<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta http-equiv="Pragma" content="no-cache" />
		<meta http-equiv="Cache-Control" content="no-cache" />
		<meta http-equiv="Expires" content="0" />
		<meta http-equiv="X-UA-Compatible" content="E=edge;chrome=1" />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<title>嘉华金融</title>
        <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/reset.css">
	    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/weui.min.css">
	    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/weui.css">
	    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/index.css">
	    <script type="text/javascript" src="<%=path%>/static/js/jquery-3.2.1.min.js"></script>
		<script type="text/javascript" src="<%=path%>/static/js/weui.min.js"></script>
		<script type="text/javascript" src="<%=path%>/static/js/zepto.min.js"></script>
		<script type="text/javascript" src="<%=path%>/static/js/feedback.js"></script>
		<script type="text/javascript" src="<%=path%>/static/layer/layer.js"></script>
		<style>
		    .text-wrap {
	            width: 100%;
	            min-height: 100px;
	            padding: 10px;
	            box-sizing: border-box;
	        }
	        .enterprise-form .weui-label {
	            margin-right: 1rem;
	        }
	        .enterprise-form .problem-text {
	            width: 6rem;
	        }
	  
	      /*  .weui-uploader__bd {
            position: relative;
            width: 80px;
            height: 81px;
          }
          .weui-uploader__input-box {
            position: absolute;
            top: 0;
            left: 0;
            /*float: none;*/
          }
           .weui-uploader__input-box.change:before {
                width: 0;
                height: 0;
          }
          .weui-uploader__input-box.change:after {
                width: 0px;
              */   height: 0px;
          } 
	        
	  </style>	
</head>
<body>
	<div>
        <div class="header">
            <div></div>
            <div>问题反馈</div>
            <div></div>
        </div>
        <div class="main">
            <div class="enterprise-form">
                <div class="weui-cells weui-cells_form">
                    <div class="weui-cell">
                        <div class="weui-cell__hd"><label class="weui-label">操作功能：</label></div>
                        <div class="weui-cell__bd">
                            <textarea onKeyDown="LimitTextArea(this)" onKeyUp="LimitTextArea(this)"
                            onkeypress="LimitTextArea(this)" name="" class="text-wrap problem oper" placeholder="请输入本次的目的，如提现，推广"></textarea>
                        </div>
                    </div>
                    <div class="weui-cell">
                        <div class="weui-cell__hd"><label class="weui-label">问题描述：</label></div>
                        <div class="weui-cell__bd">
                            <textarea onKeyDown="LimitTextArea(this)" onKeyUp="LimitTextArea(this)"
                            onkeypress="LimitTextArea(this)" name="" class="text-wrap problem des" placeholder="请尽可能详细描述操作步骤，以便于我们尽快为您解答"></textarea>
                        </div>
                    </div>
                    <div class="weui-cell">
                        <div class="weui-cell__hd upload-label"><label class="weui-label problem-text">截图：<div class="weui_cell_ft js_counter">0/3</div></label>
                       
                        </div>
                        <div class="weui-cell__bd">
                             <div class="weui_uploader_bd">
					              <ul class="weui_uploader_files">
					                <!-- 预览图插入到这 --> </ul>
					              <div class="weui_uploader_input_wrp">
					                <input class="weui_uploader_input js_file" type="file" accept="image/jpg,image/jpeg,image/png" multiple=""></div>
					             </div>
                        </div>
                    </div>
                </div>
                <div class="modify-btn-wrap">
                    <div class="error-content company-error"></div>
                    <div class="modify-btn company-btn h-btn" id="btn"><a>提交</a></div>
                </div>  
            </div>
        </div>
         <div class="weui_dialog_alert" style="display: none;">
		      <div class="weui_mask"></div>
		      <div class="weui_dialog">
		          <div class="weui_dialog_hd"><strong class="weui_dialog_title">警告</strong>
		      </div>
		       <div class="weui_dialog_bd">弹窗内容，告知当前页面信息等</div>
		      <div class="weui_dialog_ft">
		          <a href="javascript:;" class="weui_btn_dialog primary">确定</a>
		       </div>
		      </div>
		 </div>
		 <div class="weui-gallery" id="gallery">
            <span class="weui-gallery__img" id="galleryImg"></span>
            <div class="weui-gallery__opr">
                <a href="javascript:" class="weui-gallery__del">
                    <i class="weui-icon-delete weui-icon_gallery-delete"></i>
                </a>
            </div>
        </div>
      </div>
<script type="text/javascript">
   var path="<%=path%>"
   function problem(){
	   if($(".oper").val() == "" || $(".oper").val() == null) {
	          $(".error-content").text("* 请输入操作功能");
	          return false;
      }
      if($(".des").val() == "" || $(".des").val() == null) {
          $(".error-content").text("* 请输入问题描述");
          return false;
      }  
      return true;
   }
   
   var flag = true;
   var imgStr = new Array();
   $("#btn").on("touchstart",function() {
	   if(problem() && flag){
		   imgStr.splice(0,imgStr.length);
		   $(".error-content").text("");
		   $('li').each(function(){
			   var avatar = $(this).css("backgroundImage");
			   avatar = avatar.split("(")[1].split(")")[0];
			   var base64 = avatar.substr(avatar.indexOf(",")+1);
			   imgStr.push(base64)
	       })
	       if(imgStr<=0){
	    	   imgStr=JSON.stringify(imgStr);
	       }
		   flag= false;
		   $.ajax({
               url : path+"/feedback/insertFeedback.html",
               data: {
            	   operation:$(".oper").val(),
            	   description:$(".des").val(),
            	   imgStr:imgStr
               },
               type : "POST",
               datatype : "json",
               traditional: true,
               async: false,
               success : function(datas) {
            	   flag=true;
                   var json =JSON.parse(datas);
                   if(json.code==200){
                       layer.msg(json.msg, {time: 2000},function(){                                
                          window.location="<%=path%>/enFeedback/index.html";
                        });  
                   }else{
                        layer.msg(json.msg);
                   }
               }
           });   
	   }
   })
   
    // input 点击 内容消失
    setInput()
    function setInput() {
        $("textarea").focus(function() {
        //操作
            $(".error-content").text(" ");
            if($(this).val()==$(this).attr("placeholder")){
                $(this).val("").css("color","#000")
            }
        });
        $("textarea").blur(function() {
        //操作
            if($(this).val()=="")
                $(this).val($(this).attr("placeholder")).css("color","#8d8d8d")
        });
    }
   
   $("#closeImg").click(function() {
       $("#iosDialog2").css("display","none")
   });
   $('.problem').keyup(function(){
       var fz = 0;
       $('.problem').each(function(){
           if($(this).val()=="" || $(this).val() == $(this).attr("placeholder") ){
               $(".h-btn").removeClass("active")
               return;
           }
           fz++;
       })
       if(fz == $('.problem').length){
           $(".h-btn").addClass("active")
       }
   })
</script>
</body>
</html>
